import numpy as np
import time
from IPython import display
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import random


# Some helper functions

# Initialize the board with starting positions
def init_board(pos_list, my_board):
    for pos in pos_list:    #pos遍历 pos_list ,pos_list列表，每个元素是数对
        my_board[pos[0], pos[1]] = 10# pos[0]代表取 数对[5,2]中的第一个值 5 。
    return my_board



# Input variables for the board
boardsize = 5  # board will be X by X where X = boardsize
pad = 1 # padded border, do not change this!
initial_cells = 10  # this number of initial cells will be placed in randomly generated positions

my_board = np.ones((boardsize + pad, boardsize + pad))
pos_list = []
for i in range(initial_cells):
    pos_list.append([random.randint(1, boardsize), random.randint(1, boardsize)])

my_board = init_board(pos_list, my_board)


# matplotlib notebook
fig = plt.gcf() #创建画布
my_board[3,2]=0
im = plt.imshow(my_board, animated=True)


plt.show()